import {Component, OnInit, Output, EventEmitter, Input} from "@angular/core";

export class LabelWithIconComponentProperty {
    static mappingJson(obj, json) {
      for (let key in json) {
        json[key]["name"] = key;
        obj[key] = new LabelWithIconComponentProperty(json[key]);
      }
    }

    // background?: string = "red";
    name: string = "";
    height?: string = "64px";
    color?: string = "#444";
    fontSize?: string = '14px';
    key?: string = "";
    value?: string = "";
    prefixIcon?: string = "";
    suffixIcon?: string = "";
    globalClass?: string = "label-with-icon";
    ionicDatetime?: boolean = false;
    datetimeFormat?: string = "YYYY-MM-DD";
    placeholder?: string = "";
    pickerFormat?: string = "YYYY-MM-DD";
    ionToggle?: boolean = false;
    ionToggleDisabled?: boolean = false;
    ionToggleChecked?: boolean = false;
    datePipe?: boolean = false;
    datePipeFormat?: string = "yyyy-MM-dd";
    constructor(
      json = {}
    ) {
      let curObj = Object.getOwnPropertyNames(this);
      curObj.forEach((key) => {
        if (json[key]) {
          this[key] = json[key];
        }
      });
    }

}

@Component({
    selector: 'label-with-icon-component',
    templateUrl: './label-with-icon.component.html'
})

export class LabelWithIconComponent implements OnInit {
    ionicDate: string;
    isStop: boolean;
    valuePadding: string;
    @Input() properties: LabelWithIconComponentProperty;
    @Output() GetData = new EventEmitter();
    ngOnInit() {
    //

      this.valuePadding = this.properties.suffixIcon ? "3rem" : "0rem";

      // dataTime default value
      if (this.properties.ionicDatetime && this.properties.value) {
        this.ionicDate = this.properties.value;
      }
    }

    labelWithIcon() {
      this.GetData.emit(this);
    }

}

